﻿@{
    Layout = "_LayoutAdmin";
}

@model IReadOnlyList<Moonglade.Model.Category>

<h3>
    Categories
    <a class="btn btn-outline-success float-right" asp-controller="Category" asp-action="Create">
        <span class="icon-plus"></span>
        Create
    </a>
</h3>
<hr />

@if (null != ViewBag.HasError && ViewBag.HasError)
{
<div class="alert alert-danger">
    @ViewBag.ErrorMessage
</div>
}
else
{
<div class="card-columns card-columns-categories">
    @foreach (var cat in Model.OrderBy(m => m.DisplayName))
    {
    <div class="card mb-4">
        <div class="card-body">
            <h6 class="card-title">
                <a asp-controller="Category" asp-action="List" asp-route-categoryName="@cat.Name" target="_blank">
                    @cat.DisplayName
                </a>
            </h6>

            <p class="mt-2 h-30px">
                @cat.Note
            </p>

            <small class="text-muted">@cat.Name</small>
        </div>
        <div class="card-footer">
            <a asp-controller="Category" asp-action="Edit" asp-route-id="@cat.Id" class="btn btn-sm btn-primary">Edit</a>
            <a asp-controller="Category" asp-action="Delete" asp-route-id="@cat.Id" class="btn btn-sm btn-danger">Delete</a>
        </div>
    </div>
    }
</div>
}